package StreamDemo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class StreamDemo {

    public static void main(String[] args) {

//        List<String> list= Arrays.asList("1","2","p");
//        Stream<String> stream = list.stream();
//        stream.forEach(System.out::println);
//
//        String[] s=new String[]{"u","o","h"};
//        Stream<String> s1 = Stream.of(s);
//        s1.forEach(System.out::println);

//        Stream<Integer> iterate = Stream.iterate(1, (x) -> x + 1);
//        iterate.limit(10).forEach(System.out::println);

//      Stream<Integer> generate = Stream.generate(()->1);
//      generate.limit(10).forEach(System.out::println);

        //Stream为中间操作不会执行，只有算子操作才会执行
        List<Integer> integers = Arrays.asList(1, 5, 6, 7);
        Integer integer = integers.stream().filter((x) -> {
            System.out.println("运行");
           return x % 2 == 0;
        }).findAny().get();
        System.out.println(integer);

    }
}
